﻿using Fst.SemiRing;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Linguist.G2p
{
    /// <summary>
    /// @author John Salatas <jsalatas@users.sourceforge.net>
    /// </summary>
    public class Path
    {
        // the path
        private List<String> path;

        // the path's cost
        private float cost;

        // the paths' semiring
        private Semiring semiring;

        /**
        /// Create a Path instance with specified path and semiring elements
         */
        public Path(List<String> path, Semiring semiring) 
        {
            this.path = path;
            this.semiring = semiring;
            cost = this.semiring.zero();
        }

        /**
        /// Create a Path instance with specified semiring element
         */
        public Path(Semiring semiring) 
            :this(new List<String>(), semiring)
        {
            
        }

        /**
        /// Get the path
         */
        public List<String> getPath() 
        {
            return path;
        }

        /**
        /// Get the paths' cost
         */
        public float getCost() 
        {
            return cost;
        }

        /**
        /// Set the paths' cost
         */
        public void setCost(float cost) 
        {
            this.cost = cost;
        }

        /**
        /// Get the paths
         */
        public void setPath(List<String> path) 
        {
            this.path = path;
        }

        /*
        /// (non-Javadoc)
        /// 
        /// @see java.lang.Object#toString()
         */
        override
        public String ToString() 
        {
            StringBuilder sb = new StringBuilder();
            sb.Append(cost + "\t");
            foreach (String s in path) 
            {
                sb.Append(s);
                sb.Append(' ');
            }
            return sb.ToString().Trim();
        }

    }
}
